import request from '@/utils/request'

/**
 *
 * @export 获取公司结构数据
 * @return {Promise}
 */
export function getDepartments() {
  return request({
    url: '/company/department'
  })
}

/**
 *
 * @export 删除部门
 * @param {Number} id 需要删除的部门ID
 * @return {Promise}
 */
export function delDepartments(id) {
  return request({
    url: `/company/department/${id}`,
    method: 'delete'
  })
}

/**
 *
 * @export 添加部门
 * @param {object} data 新部门的相关信息
 * @return {Promise}
 */
export function addDepartments(data) {
  return request({
    url: '/company/department',
    method: 'post',
    data
  })
}

/**
 *
 * @export 获取对应部门的详细信息
 * @param {*} id
 * @return {Promise}
 */
export function getDepartDetail(id) {
  return request({
    url: `/company/department/${id}`
  })
}

/**
 *
 * @export 编辑部门
 * @param {Object} data
 * @return {Promise}
 */
export function updateDepartments(data) {
  return request({
    url: `/company/department/${data.id}`,
    method: 'put',
    data
  })
}
